package com.study.compose.beta.view

import android.app.Activity
import android.content.Intent
import android.net.Uri
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.unit.dp
import com.module.compose.base.composable.Content
import com.module.compose.base.composable.ContentView
import com.module.compose.base.composable.Title
import com.study.compose.beta.theme.RandomColor

/**
 * 作者：zhangjunfei 2021/6/7 6:25 下午
 * 主页：https://gitee.com/ZhangQQ_123/projects
 * 描述：参考借鉴
 */
@Composable
fun ReferenceSample() {
    val context = LocalContext.current as Activity
    LazyColumn(
        Modifier
            .fillMaxWidth()
            .padding(10.dp)
    ) {
        item {
            ContentView {
                Title(title = "swipe-to-refresh")
                Content(
                    content = "https://github.com/aakarshrestha/compose-swipe-to-refresh",
                    color = RandomColor.color(),
                    fontStyle = FontStyle.Italic,
                ) {
                    val uri = Uri.parse("https://github.com/aakarshrestha/compose-swipe-to-refresh")
                    val intent = Intent(Intent.ACTION_VIEW, uri)
                    context.startActivity(intent)
                }
            }
        }
        item {
            ContentView {
                Title(title = "accompanist")
                Content(
                    content = "https://github.com/google/accompanist",
                    color = RandomColor.color(),
                    fontStyle = FontStyle.Italic,
                ) {
                    val uri = Uri.parse("https://github.com/google/accompanist")
                    val intent = Intent(Intent.ACTION_VIEW, uri)
                    context.startActivity(intent)
                }
            }
        }
    }
}